Component({
  data: {
    selected: 0,
    color: '#666666',
    selectedColor: '#1890ff',
    list: [
      {
        pagePath: '/pages/index/index',
        iconPath: '/static/tabbar/home.png',
        selectedIconPath: '/static/tabbar/home-active.png',
        text: '首页'
      },
      {
        pagePath: '/pages/diary/list',
        iconPath: '/static/tabbar/diary.png',
        selectedIconPath: '/static/tabbar/diary-active.png',
        text: '日记'
      },
      {
        pagePath: '/pages/diary/edit',
        iconPath: '/static/tabbar/add.png',
        selectedIconPath: '/static/tabbar/add-active.png',
        text: '写日记'
      },
      {
        pagePath: '/pages/category/list',
        iconPath: '/static/tabbar/category.png',
        selectedIconPath: '/static/tabbar/category-active.png',
        text: '分类'
      },
      {
        pagePath: '/pages/profile/index',
        iconPath: '/static/tabbar/profile.png',
        selectedIconPath: '/static/tabbar/profile-active.png',
        text: '我的'
      }
    ]
  },
  attached() {},
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      
      // 写日记页面使用navigateTo
      if (data.index === 2) {
        wx.navigateTo({
          url
        })
      } else {
        wx.switchTab({
          url
        })
      }
      
      this.setData({
        selected: data.index
      })
    }
  }
}) 